home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-03-19 | 5.6 KB | 158 lines | [TEXT/MPS ] |
- #
- # ****************************************************************************
- #
- # File Name: TestLevel.lib
- #
- # Contains: Task dispatching mechanism for application functional scripting,
- # as well as tasks specific to performing functional tests.
- #
- # Written by: MF
- #
- # Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- #
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- #
- # Vers Date Author Description
- # ---- -------- ------ ---------------------------------------------
- # 1.0 5/23/95 MDF Created
- #
- # ****************************************************************************
-
- ########################################################################
- # External libraries
- #=======================================================================
- Libraries "ExceptionHandling.Lib","UserInterface.Lib","OutPut.Lib";
-
-
- #########################################################################
- # TestTaskDispatcher(theList)
- #========================================================================
- # Author: MDF
- # Description: This routine generates and returns a randomized list from the
- # first parameter
- # Parameters: pQLTaskList - a list of quicklook tasks
- # pFunctTaskList - a list of functional tests
- # Returns: none
- # Examples: TestTaskDispatcher({task DoText,task DoWindow},{task DoLineTool},1);
- # TestTaskDispatcher({task DoText, {task DoDraw,1,[window o:1]},
- # {task DoWindow}},{task DoLineTool},1);
- # Assumptions: Supports calling a task with up to five arguments.
- #========================================================================
- # History:
- # MDF 5/23/95 Created
- #########################################################################
- TASK TestTaskDispatcher(pQLTaskList := {},pFunctTaskList := {})
- begin
- if(pFunctTaskList)
- begin
- newFunctTaskList := {}; # initialize
- for taskNum := 1 to card(pFunctTaskList) # loop through the number of tasks in pFunctTaskList
- begin
- flagIndex := isMember(1,pFunctTaskList[taskNum]); # get the flag setting
- if(flagIndex) # if flag is true, remove flag and re-concatenate task list
- newFunctTaskList := newFunctTaskList + remove(2,pFunctTaskList[taskNum]);
- end;
- lookupTaskList := pQLTaskList + newFunctTaskList; # concatenate quicklook and functional tasks
- end;
- else
- lookupTaskList := pQLTaskList;
-
- for each randomTask in RandomList(lookupTaskList)
- begin
- if (typeof(randomTask) = 'list') # if a task has arguments associated with it
- begin
- listSize := card randomTask;
- switch listSize
- begin
- case 2: # task reference plus one argument
- call(randomTask[1],randomTask[2]);
- case 3: # task reference plus two arguments
- call(randomTask[1],randomTask[2],randomTask[3]);
- case 4: # task reference plus three arguments
- call(randomTask[1],randomTask[2],randomTask[3],
- randomTask[4]);
- case 5: # task reference plus four arguments
- call(randomTask[1],randomTask[2],randomTask[3],
- randomTask[4],randomTask[5]);
- case 6: # task reference plus five arguments
- call(randomTask[1],randomTask[2],randomTask[3],
- randomTask[4],randomTask[5],randomTask[6]);
- case 7: # task reference plus 6 arguments
- call(randomTask[1],randomTask[2],randomTask[3],
- randomTask[4],randomTask[5],randomTask[6],
- randomTask[7]);
- end;
- end;
- else # task without arguments
- begin
- println;
- call(randomTask);
- println;
- end;
- end;
- end; # TestTaskDispatcher
-
-
- #########################################################################
- # RandomList(theList)
- #========================================================================
- # Author: MDF
- # Description: This routine generates and returns a randomized list from the
- # first parameter
- # Parameters: pTheList - any list
- # Returns: randomizedList - a new randomized list
- # Examples: newList := RandomList({item1,item2,item3});
- # Assumptions: None
- #========================================================================
- # History:
- # MDF 5/23/95 Created
- #########################################################################
- TASK RandomList(pTheList)
- begin
- randomizedList := {};
-
- while pTheList
- begin
- randomIndex := random(1, card pTheList);
- randomizedList := randomizedList + {pTheList[randomIndex]};
- pTheList := remove(randomIndex, pTheList);
- end;
-
- return (randomizedList);
- end; # RandomList
-
-
- #########################################################################
- # ConvertToRelative(pPointList, pDocWind)
- #========================================================================
- # Author: MDF
- # Description: Accepts a point in global coordinates and converts it to
- # coordinates relative to the window specified.
- # Parameters: pPointList - a list of points
- # pDocWind - window descriptor
- # Returns: List of points.
- # Examples: ConvertToRelative({50,100},[window t:'Untitled' o:1]);
- # Assumptions: None
- #========================================================================
- # History:
- # MDF 5/23/95 Created
- #########################################################################
- TASK ConvertToRelative(pPointList, pDocWind := [window o:1])
- begin
- returnVal := 0; # Init error condition
-
- windDesc := FindWindow(pDocWind);
- if windDesc
- begin
- windRect := windDesc.r;
- horizWindOffset := windRect[1];
- vertWindOffset := windRect[2];
- relCoord := {pPointList[1]-horizWindOffset,
- pPointList[2]-vertWindOffset}; # this line does the conversion
- returnVal := relCoord;
- end;
-
- return(returnVal);
- end; # ConvertToRelative